package com.devilvan.betrice.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.devilvan.betrice.common.BasePo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.io.Serial;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
* @author Evad.Wu
* @Description 角色信息表 映射
* @date 2023-08-11
*/
@Setter
@Getter
@ToString(exclude = {"sysUserPoSet", "sysDeptPoSet", "sysMenuPoSet"})
@EqualsAndHashCode(callSuper = false, exclude = {"sysUserPoSet", "sysDeptPoSet", "sysMenuPoSet"})
@NoArgsConstructor
@Accessors(chain = true)
@TableName(value = "SYS_ROLE")

@Entity
@Table(name = "SYS_ROLE")
@DynamicInsert
@EntityListeners(AuditingEntityListener.class)
@Schema(description = "角色信息表 映射")
public class SysRolePo extends BasePo implements Serializable {
    @Serial
    private static final long serialVersionUID = -5506566851317765658L;
    @Schema(description = "角色ID")
    @TableField(value = "ROLE_ID")
    @Column(name = "ROLE_ID", columnDefinition = "BIGINT(19) NOT NULL COMMENT '角色ID'")
    private Long roleId;
    @Schema(description = "角色名称")
    @TableField(value = "ROLE_NAME")
    @Column(name = "ROLE_NAME", columnDefinition = "VARCHAR(30) NOT NULL COMMENT '角色名称'")
    private String roleName;
    @Schema(description = "角色权限字符串")
    @TableField(value = "ROLE_KEY")
    @Column(name = "ROLE_KEY", columnDefinition = "VARCHAR(100) NOT NULL COMMENT '角色权限字符串'")
    private String roleKey;
    @Schema(description = "显示顺序")
    @TableField(value = "ORDER_NUM")
    @Column(name = "ORDER_NUM", columnDefinition = "INT(10) NOT NULL COMMENT '显示顺序'")
    private Integer orderNum;
    @Schema(description = "数据范围（见DATA_SCOPE）")
    @TableField(value = "DATA_SCOPE")
    @Column(name = "DATA_SCOPE", columnDefinition = "CHAR(1) COMMENT '数据范围（见DATA_SCOPE）'")
    private String dataScope;
    @Schema(description = "菜单树选择项是否关联显示")
    @TableField(value = "MENU_CHECK_STRICTLY")
    @Column(name = "MENU_CHECK_STRICTLY", columnDefinition = "BIT(1) COMMENT '菜单树选择项是否关联显示'")
    private Boolean menuCheckStrictly;
    @Schema(description = "部门树选择项是否关联显示")
    @TableField(value = "DEPT_CHECK_STRICTLY")
    @Column(name = "DEPT_CHECK_STRICTLY", columnDefinition = "BIT(1) COMMENT '部门树选择项是否关联显示'")
    private Boolean deptCheckStrictly;
    @Schema(description = "备注")
    @TableField(value = "REMARK")
    @Column(name = "REMARK", columnDefinition = "VARCHAR(500) COMMENT '备注'")
    private String remark;

    @Schema(description = "角色对应的用户")
    @TableField(exist = false)
    @ManyToMany(mappedBy = "sysRolePoSet")
    private Set<SysUserPo> sysUserPoSet = new HashSet<>(0);
    @Schema(description = "角色对应的部门")
    @TableField(exist = false)
    @ManyToMany(mappedBy = "sysRolePoSet")
    private Set<SysDeptPo> sysDeptPoSet = new HashSet<>(0);
    @Schema(description = "角色对应的菜单")
    @TableField(exist = false)
    @ManyToMany(mappedBy = "sysRolePoSet")
    private Set<SysMenuPo> sysMenuPoSet = new HashSet<>(0);
}
